const randomstring = require('randomstring');
const convert = require('xml-js')
exports.genRandomStr = (len) => {
  return randomstring.generate(len)
}

exports.xml2js = (xml) => {
  let obj = convert.xml2js(xml, {
    compact: true,
    cdataKey:'value',
    textKey:'value',
  }).xml;

  //扁平化处理
  let rs = Object.keys(obj).reduce((item, key) => {
    item[key] = obj[key]['value']
    return item;
  }, {})

  return rs;


}